Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Make destructor virtual to avoid object splicing during destructor #9035

Merged
merged 2 commits into from
May 18, 2017

Conversation

kkaefer
Copy link
Contributor

@kkaefer kkaefer commented May 18, 2017

3f0c89d introduced a GeoJSONData object that is held in a unique_ptr, and has two child classes with data members. However, the unique_ptr created only holds the parent object, and it doesn't have a a virtual destructor, which means that during destruction, it'll only delete the base class part of the object (probably empty due to empty base optimization), which leaves the other data members defined by the child classes (GeoJSONVT or Supercluster) allocated, creating a memory leak.

/cc @tmpsantos @bsudekum

@kkaefer kkaefer requested a review from jfirebaugh May 18, 2017 10:43
@kkaefer kkaefer added in progress bug Core The cross-platform C++ core, aka mbgl labels May 18, 2017
@kkaefer
Copy link
Contributor Author

kkaefer commented May 18, 2017

Refs #8906

Copy link
Contributor

@tmpsantos tmpsantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This should be cherry picked to the release branch as well.

@kkaefer kkaefer merged commit eae2c71 into master May 18, 2017
@kkaefer kkaefer deleted the virtual-destructor-splicing branch May 18, 2017 14:57
@bsudekum bsudekum mentioned this pull request May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants